package com.apes.scm.masterdata.frame.model;

import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.Name;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import com.apes.framework.jpa.generator.Implementation;
import com.apes.scm.masterdata.party.model.PartyRole;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import javax.validation.constraints.NotNull;

/**
 * 功能：责任中心
 *
 * @author HuJianlin
 * @create 2018-03-08 11:23
 */
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = DutyCenter.CONST_TABLE_NAME)
public class DutyCenter extends Model {
    public static final String CONST_TABLE_NAME = "mas_duty_center";

    @Id
    @Column(name = "ID", nullable = false, length = 32)
    @Comment("中心编码")
    @ApesGenerator(code = CONST_TABLE_NAME, name = "责任中心",padding = 4,implementation = Implementation.NO_GAP)
    private String id;  //中心编码

    @Column(name = "NAME", nullable = false, length = 200)
    @Comment("中心名称")
    private String name; //中心名称

    // @ManyToOne(fetch = FetchType.LAZY)
    // @JoinColumn(name = "center_type", referencedColumnName = "id")
    // @Comment("中心类型编码")
    // private Enumeration centerType; //中心类型（cost:成本中心 ,profit:利润中心）



    @NotNull
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "company_id", referencedColumnName = "id")
    @Comment("公司编码")
    @Name
    private PartyRole company; //所属公司

    @Column(name = "valid", nullable = false, columnDefinition = "number(1,0) default 1")
    @Comment("有效")
    private boolean valid = true; //有效


    @Column(name = "cost_Center", nullable = false, columnDefinition = "number(1,0) default 1")
    @Comment("成本中心")
    private boolean costCenter ; //有效

    @Column(name = "profit_Center", nullable = false, columnDefinition = "number(1,0) default 1")
    @Comment("利润中心")
    private boolean profitCenter ; //有效



}
